package com.example.aics.tools;

import java.math.BigDecimal;

import org.springframework.stereotype.Component;

import dev.langchain4j.agent.tool.P;
import dev.langchain4j.agent.tool.Tool;
import dev.langchain4j.agent.tool.ToolMemoryId;

@Component
public class CalculatorTools {

    /** 加法 */
    @Tool(name = "sum",value = "返回相加的结果")
    public BigDecimal sum( @ToolMemoryId String memoryId , @P(value = "加法参数1",required = true) BigDecimal a , @P(value = "加法参数2",required = true) BigDecimal b){
        System.out.println("执行加法运算，memoryId为：" + memoryId + "，参数1为：" + a + "，参数2为：" + b);
        return a.add(b);
    }

    /** 减法 */
    @Tool(name = "sub",value = "返回相减的结果")
    public BigDecimal sub(@P(value = "减法参数1",required = true) BigDecimal a , @P(value = "减法参数2",required = true) BigDecimal b){
        System.out.println("执行减法运算，参数1为：" + a + "，参数2为：" + b);
        return a.subtract(b);
    }

    /** 乘法 */
    @Tool(name = "mul",value = "返回相乘的结果")
    public BigDecimal mul(@P(value = "乘法参数1",required = true) BigDecimal a , @P(value = "乘法参数2",required = true) BigDecimal b){
        System.out.println("执行乘法运算，参数1为：" + a + "，参数2为：" + b);
        return a.multiply(b);
    }

    /** 除法 */
    @Tool
    public BigDecimal div(BigDecimal a , BigDecimal b){
        return a.divide(b);
    }

    /** 平方 */
    @Tool
    public BigDecimal square(BigDecimal a){
        System.out.println("计算平方，参数为：" + a);
        return a.multiply(a);
    }

}
